package comgame.components.EquipmentComponent;

import com.almasb.fxgl.dsl.FXGL;
import comgame.entities.EquipmentEnum.BootType;

public class BootComponent extends EquipmentComponent {

    private final BootType bootType;
    private String displayName;
    public BootComponent(BootType bootType) {
        super(bootType);
        this.bootType = bootType;
        displayName = bootType.getName();
    }
    public int getAttack() {
        return bootType.getAttack();
    }
    public int getDefense() {
        return bootType.getDefense();
    }
    public int getSpeed() {
        return bootType.getSpeed();
    }
    public double getCritRate() {
        return bootType.getCritRate();
    }
    public String getDisplayName() {
        return displayName != null ? displayName : bootType.getName();
    }

    @Override
    public void onAdded() {
        super.onAdded();
        System.out.println("BootComponent onAdded 被调用");
        
        // 只更新AttributeComponent，不直接更新Player对象
        comgame.components.AttributeComponent attr = entity.getComponent(comgame.components.AttributeComponent.class);
        if (attr != null) {
            System.out.println("装备靴子: " + bootType.getName() + 
                " 攻击+" + bootType.getAttack() + 
                " 防御+" + bootType.getDefense() + 
                " 速度+" + bootType.getSpeed() +
                " 暴击率+" + String.format("%.2f", bootType.getCritRate() * 100) + "%");
        }
    }

    @Override
    public void onRemoved() {
        super.onRemoved();
        System.out.println("BootComponent onRemoved 被调用");
        // 只更新AttributeComponent，不直接更新Player对象
        comgame.components.AttributeComponent attr = entity.getComponent(comgame.components.AttributeComponent.class);
        if (attr != null) {
        }
    }

    @Override
    public String getDescription() {
        return super.getDescription() + " + 魔法抗性";
    }
}
